package dongshi.daddy.oracle;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class OracleMain {
    public static void main(String[] args) throws Exception {
        //1、导入驱动jar包
        //2、注册驱动
        Class.forName("oracle.jdbc.driver.OracleDriver");
        //3、获取数据库的连接对象
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.10.251:1521/orcl", "jc6_jcs", "jinher.2023");
        //4、定义sql语句
        String sql = "SELECT * FROM AREA ";
        //5、获取执行sql语句的对象
        Statement stat = con.createStatement();
        //6、执行获取结果
        ResultSet rs = stat.executeQuery(sql);
        while(rs.next()){
            String one = rs.getString(1);
            String two = rs.getString(2);
            System.out.println("one is: " + one + ", two is: " + two);
        }
    }
}
